package com.helper.news.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.helper.news.model.ApArticle;
import com.helper.news.service.ApArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/apArticle")
public class ApArticleController {
    @Autowired
    private ApArticleService apArticleService;

    @PostMapping
    public ApArticle create(@RequestBody ApArticle apArticle) {
        apArticleService.save(apArticle);
        return apArticle;
    }

    @GetMapping
    public List<ApArticle> list() {
        return apArticleService.list();
    }

    @GetMapping("/{id}")
    public ApArticle getById(@PathVariable Long id) {
        return apArticleService.getById(id);
    }

    @PutMapping
    public ApArticle update(@RequestBody ApArticle apArticle) {
        apArticleService.updateById(apArticle);
        return apArticle;
    }

    @DeleteMapping("/{id}")
    public void delete(@PathVariable Long id) {
        apArticleService.removeById(id);
    }
}